package com.divemotor.ventarepuestosinternet.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "TAL_MAE_VEHICULO_MODELO_FAB")
public class VehiculoModeloFabrica  implements Serializable {

	private static final long serialVersionUID = 1L;
	
	@EmbeddedId
	private VehiculoModeloFabricaPK vehiculoModeloFabricaPK;
	@Column(name = "IND_ACTIVO", length = 1)
	private String estado;
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumns({@JoinColumn(name = "COD_MODELO_FABRICA", referencedColumnName = "COD_MODELO_FABRICA", insertable = false, updatable = false),
				@JoinColumn(name = "COD_MARCA", referencedColumnName = "COD_MARCA", insertable = false, updatable = false),
				@JoinColumn(name = "COD_TIPO_COMPONENTE", referencedColumnName = "COD_TIPO_COMPONENTE", insertable = false, updatable = false)})
	private ModeloFabrica modeloFabrica;
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "NUM_CHASIS", referencedColumnName = "NUM_CHASIS", insertable = false, updatable = false)
	private Vehiculo vehiculo;
	
	public VehiculoModeloFabricaPK getVehiculoModeloFabricaPK() {
		return vehiculoModeloFabricaPK;
	}

	public void setVehiculoModeloFabricaPK(
			VehiculoModeloFabricaPK vehiculoModeloFabricaPK) {
		this.vehiculoModeloFabricaPK = vehiculoModeloFabricaPK;
	}

	public ModeloFabrica getModeloFabrica() {
		return modeloFabrica;
	}

	public void setModeloFabrica(ModeloFabrica modeloFabrica) {
		this.modeloFabrica = modeloFabrica;
	}

	public Vehiculo getVehiculo() {
		return vehiculo;
	}

	public void setVehiculo(Vehiculo vehiculo) {
		this.vehiculo = vehiculo;
	}

	public String getEstado() {
		return estado;
	}

	public void setEstado(String estado) {
		this.estado = estado;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((vehiculoModeloFabricaPK == null) ? 0 : vehiculoModeloFabricaPK.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		VehiculoModeloFabrica other = (VehiculoModeloFabrica) obj;
		if (vehiculoModeloFabricaPK == null) {
			if (other.vehiculoModeloFabricaPK != null)
				return false;
		} else if (!vehiculoModeloFabricaPK
				.equals(other.vehiculoModeloFabricaPK))
			return false;
		return true;
	}
	
}